import request from "../index";

// 根据优惠券名称和类型分页获取优惠券列表
export const getCouponList = (
  params: AdminListParams
): RpI<FlashListData<CouponList>> => request.get("/coupon/list", { params });

// 添加优惠券
export const CouponCreate = (data: CouponList): RpI<number> =>
  request.post("/coupon/create", data);

// 获取单个优惠券的详细信息
export const CouponId = (id: number): RpI<CouponList> =>
  request.get(`/coupon/${id}`);

// 根据优惠券id，使用状态，订单编号分页获取领取记录
export const CouponHistoryList = (
  params: CouponHistoryParams
): RpI<FlashListData<CouponList>> =>
  request.get("/couponHistory/list", { params });

// 修改优惠券
export const CouponUpdate = (id: number, data: CouponList) =>
  request.post(`/coupon/update/${id}`, data);

// 删除优惠券
export const CouponDelete = (id: number): RpI<number> =>
  request.post(`/coupon/delete/${id}`);
